package com.pda.gongpin.view.pagerview;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.pda.gongpin.R;


public class PointRvAdapter extends RecyclerView.Adapter<PointRvAdapter.ViewHolder> {
    int size;
    int pointPosition;

    public PointRvAdapter(int size) {
        this.size = size;
    }

    public void setSelectedPoint(int pointPosition) {
        this.pointPosition = pointPosition;
    }
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_menu_recyclerview_point_item, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        if (pointPosition == position) {
            holder.imageView.setImageResource(R.mipmap.point_seleted);
        } else {
            holder.imageView.setImageResource(R.mipmap.point_no_selected);
        }
    }


    @Override
    public int getItemCount() {
        return size;
    }


    static class ViewHolder extends RecyclerView.ViewHolder {

        ImageView imageView;

        public ViewHolder(View view) {
            super(view);
            imageView = view.findViewById(R.id.iv_point);

        }

    }


}
